<template>
  <div class="loginPage">
    <p class="title">您好,<br>欢迎登陆使用</p>
    <div class="formBox">
      <el-form :model="ruleForm" label-position="top" ref="ruleForm" :rules="rules" status-icon :hide-required-asterisk="true">
        <el-form-item label="手机号" prop="phone">
          <el-input placeholder="请输入您的手机号" v-model="ruleForm.phone"></el-input>
        </el-form-item>
        <el-form-item label="密码" prop="pass">
          <el-input type="password" placeholder="请输入您的密码" v-model="ruleForm.pass"></el-input>
        </el-form-item>
        <p class="forget" @click="handleForget">忘记密码</p>
        <el-form-item>
          <div class="login" @click="handlelogin('ruleForm')">登录</div>
        </el-form-item>
        <el-form-item>
          <div class="download">APP下载</div>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: 'login-page',
  data() {
    return {
      ruleForm: {
        phone: '',
        pass: ''
      },
      rules: {
        phone: [
          { required: true, message: '请输入电话', trigger: 'blur' }
        ],
        pass: [
          { required: true, message: '请输入密码', trigger: 'blur' },
          { min: 6, max: 8, message: '长度在 6 到 8 个字符', trigger: 'blur' }
        ],
      }
    }
  },
  methods: {
    handlelogin(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!');
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    handleForget(){
      alert('忘记密码')
    }
  }
}
</script>

<style lang="scss" scoped>
.loginPage {
  position: relative;
  width: 100vw;
  height: 100vh;
  background-color: #5aa36c;

  .title {
    position: absolute;
    bottom: 400px;
    left: 20px;
    margin: 0;
    font-size: 30px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 2px;
  }

  .formBox {
    position: absolute;
    padding: 15px 30px;
    box-sizing: border-box;
    width: 100%;
    background-color: #fff;
    left: 0;
    bottom: 0;
    border-radius: 30px 30px 0 0;

    .forget {
      height: 40px;
      line-height: 40px;
      font-size: 13px;
      color: #c0c4cc;
    }

    .el-form-item {
      margin-bottom: 10px;

      :deep(.el-form-item__label) {
        margin-top: 20px;
        padding: 0;
        font-weight: 700;
        font-size: 15px;
        color: #000;
        height: 20px;
        line-height: 20px;
      }

      :deep(.el-input__inner) {
        border: none;
        border-radius: 0;
        border-bottom: 1px solid #e2e2e2;
        padding: 0;
      }
    }

    .login {
      width: 100%;
      height: 40px;
      line-height: 40px;
      text-align: center;
      background-color: #69a25b;
      color: #fff;
      border-radius: 20px;
      font-weight: 700;
      font-size: 15px;
      letter-spacing: 2px;
    }

    .download {
      width: 100%;
      height: 40px;
      line-height: 40px;
      text-align: center;
      background-color: #f6f7fb;
      border-radius: 20px;
      font-weight: 700;
      font-size: 15px;
      letter-spacing: 1px;
    }
  }
}
</style>